:art: Remove ThermometerMeasureInfo relative

huangqimin001 3 gadi atpakaļ
vecāks
revīzija
db81686eda
5 mainītis faili ar 22 papildinājumiem un 115 dzēšanām
  1. 0 16
      api/point_views.py
  2. 0 2
      api/urls.py
  3. 2 8
      equipment/admin.py
  4. 20 0
      equipment/migrations/0014_auto_20210817_1902.py
  5. 0 89
      equipment/models.py

+ 0 - 16
api/point_views.py

@@ -13,22 +13,6 @@ from utils.error.errno_utils import IsolationPointStatusCode
13 13
 
14 14
 
15 15
 @logit
16
-def measure_window(request):
17
-    point_id = request.POST.get('point_id', '')
18
-    point_measure_window = get_query_value(request, 'point_measure_window', val_cast_type='listjson')
19
-
20
-    try:
21
-        point = IsolationPointInfo.objects.get(point_id=point_id, status=True)
22
-    except IsolationPointInfo.DoesNotExist:
23
-        return response(IsolationPointStatusCode.ISOLATIONPOINT_NOT_FOUND)
24
-
25
-    point.point_measure_window = point_measure_window
26
-    point.save()
27
-
28
-    return response()
29
-
30
-
31
-@logit
32 16
 def get_point_list(request):
33 17
     page = request.POST.get('page', 1)
34 18
     num = request.POST.get('num', 20)

+ 0 - 2
api/urls.py

@@ -29,8 +29,6 @@ urlpatterns += [
29 29
 ]
30 30
 
31 31
 urlpatterns += [
32
-    url(r'^point/measure_window$', point_views.measure_window, name='measure_window'),
33
-
34 32
     url(r'^point/list$', point_views.get_point_list, name='point_list'),
35 33
     url(r'^point/info$', point_views.get_point_info, name='point_info'),
36 34
 ]

+ 2 - 8
equipment/admin.py

@@ -4,7 +4,7 @@ from django.contrib import admin
4 4
 from django_admin import ReadOnlyModelAdmin
5 5
 
6 6
 from equipment.models import (IsolationPointFieldPoolInfo, IsolationPointInfo, IsolationPointUserInfo,
7
-                              ThermometerEquipmentInfo, ThermometerMeasureInfo, ThermometerMeasureLogInfo)
7
+                              ThermometerEquipmentInfo, ThermometerMeasureLogInfo)
8 8
 
9 9
 
10 10
 class IsolationPointFieldPoolInfoAdmin(admin.ModelAdmin):
@@ -12,7 +12,7 @@ class IsolationPointFieldPoolInfoAdmin(admin.ModelAdmin):
12 12
 
13 13
 
14 14
 class IsolationPointInfoAdmin(admin.ModelAdmin):
15
-    list_display = ('point_id', 'point_name', 'point_measure_window', 'point_fields', 'limit_scene_qrcode_url', 'status', 'updated_at', 'created_at')
15
+    list_display = ('point_id', 'point_name', 'point_fields', 'limit_scene_qrcode_url', 'status', 'updated_at', 'created_at')
16 16
 
17 17
 
18 18
 class IsolationPointUserInfoAdmin(admin.ModelAdmin):
@@ -24,11 +24,6 @@ class ThermometerEquipmentInfoAdmin(ReadOnlyModelAdmin, admin.ModelAdmin):
24 24
     list_filter = ('point_id', 'status')
25 25
 
26 26
 
27
-class ThermometerMeasureInfoAdmin(ReadOnlyModelAdmin, admin.ModelAdmin):
28
-    list_display = ('point_id', 'point_measure_ymd', 'point_measure_window', 'macid', 'sn', 'temperature', 'status', 'updated_at', 'created_at')
29
-    list_filter = ('point_id', 'status')
30
-
31
-
32 27
 class ThermometerMeasureLogInfoAdmin(ReadOnlyModelAdmin, admin.ModelAdmin):
33 28
     list_display = ('point_id', 'macid', 'sn', 'name', 'sex', 'birth_stamp', 'phone', 'start_stamp', 'end_stamp', 'temperature', 'temperature_src', 'status', 'updated_at', 'created_at')
34 29
     list_filter = ('point_id', 'temperature_src', 'status')
@@ -38,5 +33,4 @@ admin.site.register(IsolationPointFieldPoolInfo, IsolationPointFieldPoolInfoAdmi
38 33
 admin.site.register(IsolationPointInfo, IsolationPointInfoAdmin)
39 34
 admin.site.register(IsolationPointUserInfo, IsolationPointUserInfoAdmin)
40 35
 admin.site.register(ThermometerEquipmentInfo, ThermometerEquipmentInfoAdmin)
41
-admin.site.register(ThermometerMeasureInfo, ThermometerMeasureInfoAdmin)
42 36
 admin.site.register(ThermometerMeasureLogInfo, ThermometerMeasureLogInfoAdmin)

+ 20 - 0
equipment/migrations/0014_auto_20210817_1902.py

@@ -0,0 +1,20 @@
1
+# Generated by Django 3.2.6 on 2021-08-17 11:02
2
+
3
+from django.db import migrations
4
+
5
+
6
+class Migration(migrations.Migration):
7
+
8
+    dependencies = [
9
+        ('equipment', '0013_isolationpointuserinfo_temperature'),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.DeleteModel(
14
+            name='ThermometerMeasureInfo',
15
+        ),
16
+        migrations.RemoveField(
17
+            model_name='isolationpointinfo',
18
+            name='point_measure_window',
19
+        ),
20
+    ]

+ 0 - 89
equipment/models.py

@@ -50,33 +50,6 @@ class IsolationPointFieldPoolInfo(BaseModelMixin):
50 50
 
51 51
 
52 52
 class IsolationPointInfo(BaseModelMixin):
53
-    DEFAULT_POINT_MEASURE_WINDOW = [
54
-        {"start": "0:00", "end": "1:00"},
55
-        {"start": "1:00", "end": "2:00"},
56
-        {"start": "2:00", "end": "3:00"},
57
-        {"start": "3:00", "end": "4:00"},
58
-        {"start": "4:00", "end": "5:00"},
59
-        {"start": "5:00", "end": "6:00"},
60
-        {"start": "6:00", "end": "7:00"},
61
-        {"start": "7:00", "end": "8:00"},
62
-        {"start": "8:00", "end": "9:00"},
63
-        {"start": "9:00", "end": "10:00"},
64
-        {"start": "10:00", "end": "11:00"},
65
-        {"start": "11:00", "end": "12:00"},
66
-        {"start": "12:00", "end": "13:00"},
67
-        {"start": "13:00", "end": "14:00"},
68
-        {"start": "14:00", "end": "15:00"},
69
-        {"start": "15:00", "end": "16:00"},
70
-        {"start": "16:00", "end": "17:00"},
71
-        {"start": "17:00", "end": "18:00"},
72
-        {"start": "18:00", "end": "19:00"},
73
-        {"start": "19:00", "end": "20:00"},
74
-        {"start": "20:00", "end": "21:00"},
75
-        {"start": "21:00", "end": "22:00"},
76
-        {"start": "22:00", "end": "23:00"},
77
-        {"start": "23:00", "end": "24:00"},
78
-    ]
79
-
80 53
     point_id = ShortUUIDField(_('point_id'), max_length=32, blank=True, null=True, help_text='隔离点唯一标识', db_index=True, unique=True)
81 54
     point_name = models.CharField(_('point_name'), max_length=255, blank=True, null=True, help_text='隔离点名称')
82 55
 
@@ -87,9 +60,6 @@ class IsolationPointInfo(BaseModelMixin):
87 60
     # }
88 61
     point_fields = JSONField(_('point_fields'), default=[], blank=True, null=True, help_text='字段列表')
89 62
 
90
-    # [{"start": "8:00", "end": "9:00"}, {"start": "12:00", "end": "14:00"}]
91
-    point_measure_window = JSONField(_('point_measure_window'), default=DEFAULT_POINT_MEASURE_WINDOW, blank=True, null=True, help_text='隔离点测温时间段')
92
-
93 63
     limit_scene_qrcode_url = models.CharField(_('limit_scene_qrcode_url'), max_length=255, blank=True, null=True, help_text='字段二维码')
94 64
 
95 65
     class Meta:
@@ -106,34 +76,9 @@ class IsolationPointInfo(BaseModelMixin):
106 76
             'point_id': self.point_id,
107 77
             'point_name': self.point_name,
108 78
             'point_fields': self.point_fields,
109
-            'point_measure_window': self.point_measure_window,
110 79
             'qrcode_url': qrcode_url,
111 80
         }
112 81
 
113
-    @property
114
-    def current_measure_window(self):
115
-        current_ymd = tc.local_string(format='%Y-%m-%d')
116
-        current_dt = tc.utc_datetime()
117
-        for window in self.point_measure_window:
118
-            start_t, end_t = window.get('start'), window.get('end')
119
-            start_dt = tc.string_to_utc_datetime(f'{current_ymd} {start_t}:00')
120
-            end_dt = tc.string_to_utc_datetime(f'{current_ymd} {end_t}:00')
121
-            if tc.utc_datetime(start_dt) < current_dt < tc.utc_datetime(end_dt):
122
-                return f'{start_t}-{end_t}'
123
-        return ''
124
-
125
-    @property
126
-    def previous_measure_window(self):
127
-        current_ymd = tc.local_string(format='%Y-%m-%d')
128
-        current_dt = tc.utc_datetime()
129
-        for window in self.point_measure_window:
130
-            start_t, end_t = window.get('start'), window.get('end')
131
-            start_dt = tc.string_to_utc_datetime(f'{current_ymd} {start_t}:00')
132
-            end_dt = tc.string_to_utc_datetime(f'{current_ymd} {end_t}:00')
133
-            if tc.utc_datetime(start_dt, minutes=60) < current_dt < tc.utc_datetime(end_dt, minutes=60):
134
-                return f'{start_t}-{end_t}'
135
-        return ''
136
-
137 82
 
138 83
 class IsolationPointUserInfo(BaseModelMixin):
139 84
     HAS_NOT_UPLOAD = '未上报'
@@ -280,40 +225,6 @@ class ThermometerEquipmentInfo(BaseModelMixin):
280 225
         }
281 226
 
282 227
 
283
-class ThermometerMeasureInfo(BaseModelMixin):
284
-    point_id = models.CharField(_('point_id'), max_length=32, blank=True, null=True, help_text='隔离点唯一标识', db_index=True)
285
-
286
-    point_measure_ymd = models.CharField(_('point_measure_ymd'), max_length=10, blank=True, null=True, help_text='隔离点测温日期', db_index=True)
287
-    point_measure_window = models.CharField(_('point_measure_window'), max_length=16, blank=True, null=True, help_text='隔离点测温时间段', db_index=True)
288
-
289
-    macid = models.CharField(_('macid'), max_length=32, blank=True, null=True, help_text='设备号')
290
-    sn = models.CharField(_('sn'), max_length=32, blank=True, null=True, help_text='序列号')
291
-
292
-    temperature = models.FloatField(_('temperature'), default=0, help_text='用户体温')
293
-
294
-    class Meta:
295
-        verbose_name = _('测温信息')
296
-        verbose_name_plural = _('测温信息')
297
-
298
-        unique_together = (
299
-            ('point_id', 'point_measure_ymd', 'point_measure_window', 'macid')
300
-        )
301
-
302
-    def __unicode__(self):
303
-        return self.pk
304
-
305
-    @property
306
-    def data(self):
307
-        return {
308
-            'point_id': self.point_id,
309
-            'point_measure_window': self.point_measure_window,
310
-            'macid': self.macid,
311
-            'sn': self.sn,
312
-            'temperature': self.temperature,
313
-            'updated_at': tc.local_string(utc_dt=self.updated_at, format='%m-%d %H:%M'),
314
-        }
315
-
316
-
317 228
 class ThermometerMeasureLogInfo(BaseModelMixin):
318 229
     CALLBACK = 1
319 230
     MQTT = 2